home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
5
< prev
next >
Wrap
Internet Message Format
|
1996-08-06
|
3KB
Path: lyra.csx.cam.ac.uk!nmm1
From: nmm1@cus.cam.ac.uk (Nick Maclaren)
Newsgroups: comp.std.c
Subject: Re: Circular buffering for FILEs? Why not?
Date: 2 Jan 1996 10:32:21 GMT
Organization: University of Cambridge, England
Message-ID: <4cb1jl$2gb@lyra.csx.cam.ac.uk>
References: <4c9i65$3b6@segfault.monkeys.com> <4c9q8e$63i@access2.digex.net> <4ca1ik$ffa@engnews2.Eng.Sun.COM>
NNTP-Posting-Host: ursa.cus.cam.ac.uk
In article <4ca1ik$ffa@engnews2.Eng.Sun.COM>, corbett@lupa.eng.sun.com (Robert Corbett) writes:
|> In article <4c9q8e$63i@access2.digex.net>,
|> John Cochran <jdc@access2.digex.net> wrote:
|> >In article <4c9i65$3b6@segfault.monkeys.com>,
|> >Ronald F. Guilmette <rfg@monkeys.com> wrote:
|> >>I have a question about the traditional implementation of buffered FILEs.
|> >>
|> >>From this fact I deduce that traditional implementations of the entire
|> >>stdio set of functions _do not_ treat FILE buffers as so-called ``circular
|> >>buffers'' but rather treat them a mere linear buffers.
|> >>
|> >>My question is just this... Why?
|> >Why bother?
|>
|> "Why bother" is the correct answer. The reasons given (which I have
|> deleted) are correct, but not complete. A higher-level explanation
|> might prove helpful. Circular buffering is useful when I/O and
|> processing can be overlapped. Circular buffering allows sequential I/O
|> to read ahead or write behind while the data already read is being
|> processed or the next batch of data to be written is being computed.
|> Since C has no notion of overlapped I/O and processing, circular
|> buffering not useful in implementing the C I/O library. The underlying
|> OS might support overlapped I/O and processing. The OS, therefore,
|> might well be using circular buffers when dealing with sequential
|> devices. For direct access devices, the popular buffering schemes
|> tend to be more complex than circular buffering.
This isn't quite complete, either! "Since C has no notion of overlapped
I/O and processing, ..." is true but misleading.
If the operating system uses C's buffers and buffer pointers directly
(e.g. by the use of volatile, hardware interrupts on flagged values etc.),
then it might well be worth using circular buffers. But this is a very
1960s way of implementing I/O and is not, as far as I know, done by any
existing system.
Nick Maclaren,
University of Cambridge Computer Laboratory,
New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
Email: nmm1@cam.ac.uk
Tel.: +44 1223 334761 Fax: +44 1223 334679